<template>
	<z-nav-bar title="系统设置"></z-nav-bar>
	<view class="item-box" @click="cancelAccount">
		<view class="item flex_sbc">
			<view>注销账号</view>
			<image :src="setting.oss_pub_domain + '/app-img/icon/more.png'" class="icon-size-32 uni-ml-12"></image>
		</view>
	</view>
</template>

<script setup>
import { getCurrentInstance } from 'vue';
const { proxy: that } = getCurrentInstance();
import { cancelAccounts } from '@/api/my.js'
function cancelAccount() {
	uni.showModal({
		content: '注销后将无法登录，确认要注销吗？',
		title: '警告',
		success: res => {
			if (res.cancel) return
			setTimeout(() => {
				uni.showModal({
					content: '确认要注销吗？',
					title: '警告',
					success: res => {
						if (res.cancel) return
						setTimeout(() => {
							uni.showModal({
								content: '确认确认要注销吗？',
								title: '警告',
								success: res => {
									if (res.cancel) return
									cancelAccounts().then(res => {
										that.tools.alert('账号已注销')
										uni.removeStorageSync('token')
										uni.reLaunch({
											url: '/pages/my/login/login'
										})
									})
								}
							})
						}, 200)
					}
				})
			}, 200)
		}
	})
}
</script>

<style lang="scss">
page {
	background: $uni-F5F5F5;
}
</style>

<style lang="scss" scoped>
.item-box {
	width: 100vw;
	background: $uni-white;
	box-sizing: border-box;
	padding: 0 32rpx;
	.item {
		width: 100%;
		height: 112rpx;
		border-bottom: 2rpx solid $uni-F5F5F5;
		color: #333336;
		font-size: 32rpx;
	}
	.user-head {
		width: 80rpx;
		height: 80rpx;
		border-radius: 40rpx;
	}
}

.right-box {
	width: 400rpx;
	text-align: right;
}
</style>
